import type { Dayjs } from 'dayjs';

import type { PageParam, PageResult } from '@vben/request';

import { requestClient } from '#/api/request';

export namespace HolidaySchoolApi {
  /** 学校假期信息 */
  export interface HolidaySchool {
    id: number; // 假期id
    naturalYear: string; // 自然年度
    academicYear: string; // 学年
    schoolId: number; // 学校id
    holidayName?: string; // 假期名称
    infraHolidayId: number; // 全局假期id
    holidayType?: number; // 假期类型：1-寒假 2-暑假 3-法定节假日 4-春假 5-秋假 6-其他
    startDate?: Dayjs | string; // 开始日期
    endDate?: Dayjs | string; // 结束日期
    remark: string; // 备注
    status?: number; // 有效状态
    areaCode: number; // 所属行政区划
    isDefault?: boolean; // 是否默认
  }
}

/** 查询学校假期分页 */
export function getHolidaySchoolPage(
  data: PageParam,
  desensitize: boolean,
  encrypt: boolean,
) {
  return requestClient.post<PageResult<HolidaySchoolApi.HolidaySchool>>(
    '/edu/base/holiday-school/page',
    data,
    { desensitize, encrypt },
  );
}
/** 查询学校假期分页 默认*/
export function getHolidaySchoolPageDefault(
  data: PageParam,
  desensitize: boolean,
  encrypt: boolean,
) {
  return requestClient.post<PageResult<HolidaySchoolApi.HolidaySchool>>(
    '/edu/base/holiday-school/page-default',
    data,
    { desensitize, encrypt },
  );
}

/** 查询学校假期详情 */
export function getHolidaySchool(id: number) {
  return requestClient.get<HolidaySchoolApi.HolidaySchool>(
    `/edu/base/holiday-school/get?id=${id}`,
  );
}

/** 新增学校假期 */
export function createHolidaySchool(data: HolidaySchoolApi.HolidaySchool) {
  return requestClient.post('/edu/base/holiday-school/create', data);
}

/** 修改学校假期 */
export function updateHolidaySchool(data: HolidaySchoolApi.HolidaySchool) {
  return requestClient.put('/edu/base/holiday-school/update', data);
}

/** 删除学校假期 */
export function deleteHolidaySchool(id: number) {
  return requestClient.delete(`/edu.base/holiday-school/delete?id=${id}`);
}

/** 批量删除学校假期 */
export function deleteHolidaySchoolList(ids: number[]) {
  return requestClient.delete(
    `/edu/base/holiday-school/delete-list?ids=${ids.join(',')}`,
  );
}

/** 导出学校假期 */
export function exportHolidaySchool(params: any) {
  return requestClient.download('/edu/base/holiday-school/export-excel', {
    params,
  });
}
/** 更新学校默认假期状态 */
export function updateHolidaySchoolStatus(data: {
  id: number;
  status: number;
}) {
  return requestClient.put(
    '/edu/base/holiday-school/update-default-status',
    data,
  );
}
